package user_mgt

import "net/http"

func Run() {
	// 获取服务
	employeeImpl := &EmployeeImpl{}
	adminImpl := &AdminImpl{}

	// 注册 HTTP 服务
	http.Handle("/api/EmployeeLogin", employeeImpl.CorsMiddleware(employeeImpl.PostOnlyMiddleware(http.HandlerFunc(employeeImpl.HandleLogin))))
	http.Handle("/api/AdminLogin", adminImpl.CorsMiddleware(adminImpl.PostOnlyMiddleware(http.HandlerFunc(adminImpl.HandleLogin))))
	http.Handle("/api/AddCourse", adminImpl.CorsMiddleware(adminImpl.PostOnlyMiddleware(adminImpl.AuthMiddleware(http.HandlerFunc(adminImpl.HandleAddCourse)))))
	http.Handle("/api/GetEmployeeInfo", employeeImpl.CorsMiddleware(employeeImpl.GetOnlyMiddleware(employeeImpl.AuthMiddleware(http.HandlerFunc(employeeImpl.HandleGetInfo)))))

	logger.Infof("start usermgt module service successfully")
}
